render: Make rendering the background a single function
authorBenjamin Otte <otte@redhat.com>
Wed, 8 Oct 2014 01:26:01 +0000 (03:26 +0200)
committerBenjamin Otte <otte@redhat.com>
Wed, 8 Oct 2014 03:20:30 +0000 (05:20 +0200)
gtk/gtkrender.c
gtk/gtkthemingbackground.c
gtk/gtkthemingbackgroundprivate.h

index 28487bde5f2bce95ca186e420c7418bbdab07589..a7f7bef28120d326783e7588974ba158ec5c27cb 100644 (file)
@@ -492,14 +492,11 @@ gtk_do_render_background (GtkStyleContext *context,
                           gdouble          width,
                           gdouble          height)
 {
-  GtkThemingBackground bg;
-
-  _gtk_theming_background_init (&bg, context,
-                                x, y,
-                                width, height,
-                                gtk_style_context_get_junction_sides (context));
-
-  _gtk_theming_background_render (&bg, cr);
+  gtk_theming_background_render (context,
+                                 cr,
+                                 x, y,
+                                 width, height,
+                                 gtk_style_context_get_junction_sides (context));
 }
 
 /**
@@ -1580,7 +1577,6 @@ gtk_do_render_extension (GtkStyleContext *context,
                          gdouble          height,
                          GtkPositionType  gap_side)
 {
-  GtkThemingBackground bg;
   GtkJunctionSides junction = 0;
   guint hidden_side = 0;
 
@@ -1604,11 +1600,11 @@ gtk_do_render_extension (GtkStyleContext *context,
       break;
     }
 
-  _gtk_theming_background_init (&bg, context, 
-                                x, y,
-                                width, height,
-                                junction);
-  _gtk_theming_background_render (&bg, cr);
+  gtk_theming_background_render (context, 
+                                 cr,
+                                 x, y,
+                                 width, height,
+                                 junction);
 
   render_frame_internal (context, cr,
                          x, y, width, height,
index f622a4365742b073cd7df6dc9ff2d8f0b9ecd62f..e2b251b89f1aafad0ba451f215ee97ee69965cef 100644 (file)
  */
 #include "fallback-c89.c"
 
+typedef struct _GtkThemingBackground GtkThemingBackground;
+
+struct _GtkThemingBackground {
+  GtkStyleContext *context;
+
+  cairo_rectangle_t paint_area;
+  GtkRoundedBox border_box;
+  GtkRoundedBox padding_box;
+  GtkRoundedBox content_box;
+
+  GtkJunctionSides junction;
+  GdkRGBA bg_color;
+};
+
 static const GtkRoundedBox *
 gtk_theming_background_get_box (GtkThemingBackground *bg,
                                 GtkCssArea            area)
@@ -308,63 +322,44 @@ _gtk_theming_background_init_context (GtkThemingBackground *bg)
 }
 
 void
-_gtk_theming_background_init (GtkThemingBackground *bg,
-                              GtkStyleContext      *context,
-                              gdouble               x,
-                              gdouble               y,
-                              gdouble               width,
-                              gdouble               height,
-                              GtkJunctionSides      junction)
+gtk_theming_background_render (GtkStyleContext      *context,
+                               cairo_t              *cr,
+                               gdouble               x,
+                               gdouble               y,
+                               gdouble               width,
+                               gdouble               height,
+                               GtkJunctionSides      junction)
 {
-  g_assert (bg != NULL);
-
-  bg->context = context;
+  GtkThemingBackground bg;
+  gint idx;
+  GtkCssValue *background_image;
 
-  bg->paint_area.x = x;
-  bg->paint_area.y = y;
-  bg->paint_area.width = width;
-  bg->paint_area.height = height;
+  bg.context = context;
 
-  bg->junction = junction;
+  bg.paint_area.x = x;
+  bg.paint_area.y = y;
+  bg.paint_area.width = width;
+  bg.paint_area.height = height;
 
-  _gtk_theming_background_init_context (bg);
-}
+  bg.junction = junction;
 
-void
-_gtk_theming_background_render (GtkThemingBackground *bg,
-                                cairo_t              *cr)
-{
-  gint idx;
-  GtkCssValue *background_image;
+  _gtk_theming_background_init_context (&bg);
 
-  background_image = _gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_IMAGE);
+  background_image = _gtk_style_context_peek_property (bg.context, GTK_CSS_PROPERTY_BACKGROUND_IMAGE);
 
   cairo_save (cr);
-  cairo_translate (cr, bg->paint_area.x, bg->paint_area.y);
+  cairo_translate (cr, bg.paint_area.x, bg.paint_area.y);
 
-  _gtk_theming_background_apply_shadow (bg, cr, FALSE); /* Outset shadow */
+  _gtk_theming_background_apply_shadow (&bg, cr, FALSE); /* Outset shadow */
 
-  _gtk_theming_background_paint_color (bg, cr, background_image);
+  _gtk_theming_background_paint_color (&bg, cr, background_image);
 
   for (idx = _gtk_css_array_value_get_n_values (background_image) - 1; idx >= 0; idx--)
     {
-      _gtk_theming_background_paint_layer (bg, idx, cr);
+      _gtk_theming_background_paint_layer (&bg, idx, cr);
     }
 
-  _gtk_theming_background_apply_shadow (bg, cr, TRUE);  /* Inset shadow */
+  _gtk_theming_background_apply_shadow (&bg, cr, TRUE);  /* Inset shadow */
 
   cairo_restore (cr);
 }
-
-gboolean
-_gtk_theming_background_has_background_image (GtkThemingBackground *bg)
-{
-  GtkCssImage *image;
-  GtkCssValue *value = _gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_IMAGE);
-
-  if (_gtk_css_array_value_get_n_values (value) == 0)
-    return FALSE;
-
-  image = _gtk_css_image_value_get_image (_gtk_css_array_value_get_nth (value, 0));
-  return (image != NULL);
-}
index cb1f6000931dd2b3619257576247c9706cf5c9fb..eebf2e53223b8eeb9cc64307d5935c8ebf709b24 100644 (file)
 
 G_BEGIN_DECLS
 
-typedef struct _GtkThemingBackground GtkThemingBackground;
-
-struct _GtkThemingBackground {
-  GtkStyleContext *context;
-
-  cairo_rectangle_t paint_area;
-  GtkRoundedBox border_box;
-  GtkRoundedBox padding_box;
-  GtkRoundedBox content_box;
-
-  GtkJunctionSides junction;
-  GdkRGBA bg_color;
-};
-
-void _gtk_theming_background_init (GtkThemingBackground *bg,
-                                   GtkStyleContext      *context,
-                                   gdouble               x,
-                                   gdouble               y,
-                                   gdouble               width,
-                                   gdouble               height,
-                                   GtkJunctionSides      junction);
-
-void _gtk_theming_background_render (GtkThemingBackground *bg,
-                                     cairo_t              *cr);
-
-gboolean _gtk_theming_background_has_background_image (GtkThemingBackground *bg);
+void gtk_theming_background_render  (GtkStyleContext      *context,
+                                     cairo_t              *cr,
+                                     gdouble               x,
+                                     gdouble               y,
+                                     gdouble               width,
+                                     gdouble               height,
+                                     GtkJunctionSides      junction);
 
 G_END_DECLS